﻿using System;
using System.Linq.Expressions;
using System.Runtime.Serialization;

namespace Emico.Linq.Criterion
{
    [Serializable()]
    public class OrExpression<T> : LogicalExpression<T>
        where T : class
    {
        #region Constructors

        public OrExpression(IExpression<T> lhs, IExpression<T> rhs)
            : base(lhs, rhs)
        {
        }

        protected OrExpression(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

        #endregion

        #region Implement Abstract Method

        public override Expression ToLinqExpression(Criteria<T> criteria, ParameterExpression parameter)
        {
            Type t = typeof(T);
            Expression filter = Expression.Or(this.LHS.ToLinqExpression(criteria, parameter), this.RHS.ToLinqExpression(criteria, parameter));
            return filter;
        }

        #endregion
    }
}
